<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>控制器应该尽可能保持短小精悍</title>
		<script type="text/javascript" src="../angular.js">
		</script>
	</head>

	<body ng-app="MyApp">
		<div ng-controller="parentController">
			<div ng-controller="childController">
				<a ng-click="sayhello()">Say&nbsp;&nbsp;Hello</a>
			</div>
			{{person}}
		</div>
		<script type="text/javascript">
			var app = angular.module("MyApp", []);
			app.controller("parentController", function($scope) {
				$scope.person = {
					greeted: false
				}

			});
			//子控制器可以调用父类声明的变量，并进行修改值
			app.controller("childController", function($scope) {
				$scope.sayhello = function() {
					$scope.person.name = "sha"
				}

			});
		</script>
	</body>

</html>